<?php
namespace app\admin\controller;

use app\admin\tool\Parser;
use app\common\model\Customer as CustomerModel;
use tests\thinkphp\library\think\cache\driver\redisTest;
use think\Request;

class Customer extends Base{

    /**
     * 我的客户列表
     */
    public function index(Request $request){
        $param = $request->param();

        $where = ['invite_id'=>$this->admin->invitecode];
        if(!empty($param['name'])) $where['name'] = ['like',"%".$param['name']."%"];
        if(!empty($param['mobile'])) $where['mobile'] = ['like',"%".$param['mobile']."%"];

        $model = CustomerModel::where($where)->paginate(10,false,['query'=>$param]);

        $this->data['title'] = '我的客户';
        $this->data['column'] = $this->column();
        $this->data['model'] = $model;
        $this->data['parser'] = new Parser();
        $this->data['query'] = $param;

        return view('',$this->data);
    }

    /**
     * 我的二维码
     */
    public function inviteCode(){
        $this->data['title']='我的推广二维码';
        $this->data['invitecode'] = $this->admin->invitecode;
        return view('',$this->data);
    }

    protected function column(){
        return [
            'name'=>['name'=>'姓名','fun'=>'text','options'=>''],
            'mobile'=>['name'=>'手机','fun'=>'text','options'=>''],
            'invite_id'=>['name'=>'邀请人邀请码','fun'=>'text','options'=>''],
            'add_time'=>['name'=>'报名时间','fun'=>'datetime','options'=>['format'=>'Y-m-d H:i']]
        ];
    }


}